<template>
  <div>
    <el-container>
      <el-main>
        <el-card>
          <div slot="header" class="clearfix">
            <span>员工离职访谈表</span>
          </div>
          <resign-talk :form="form" :isinput=false></resign-talk>
          <el-button type="primary" style="width: 100%" @click="postresigntalk"
            >提交</el-button
          >
        </el-card>
      </el-main>
    </el-container>
  </div>
</template>
  
  <script>
import ResignTalk from "./ResignTalk.vue";
export default {
  components: { ResignTalk },

  created() {
    this.getUrlKey();
  },

  data() {
    return {
      form: { reason: [], improve: [] },
      posterid: "",
      userid:"",
    
    };
  },

  methods: {
    getUrlKey() {
      var url = window.location.href; //获取当前url
      this.nowurl = url;
      var dz_url = url.split("#")[0]; //获取#/之前的字符串
      var cs = dz_url.split("?")[1]; //获取?之后的参数字符串
      var cs_arr = cs.split("&"); //参数字符串分割为数组
      var cs = {};
      for (var i = 0; i < cs_arr.length; i++) {
        //遍历数组，拿到json对象
        cs[cs_arr[i].split("=")[0]] = cs_arr[i].split("=")[1];
      }
      this.posterid = cs.posterid;
      this.userid = cs.userid;
    },

    postresigntalk() {
      this.$confirm("即将提交访谈记录, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          let datas = {
            form: this.form,
            userid: this.userid,
            postid: this.posterid,
          };
          this.$axios
            .post("api/resign/postresigntalk", datas)
            .then((response) => {
              this.$notify({
                title: "离职访谈",
                message: "提交成功",
                type: "success",
                duration: 1500,
              });
            })
            .catch(function (error) {
              console.log(error);
            });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消",
          });
        });
    },
  },
};
</script>
  
  <style lang="scss" scoped>
</style>